package main
{
    import flash.events.Event;
    import mx.controls.Alert;
    import mx.controls.CheckBox;
    import mx.events.FlexEvent;
    
    
    
    public class ICheckBox extends CheckBox
    {
        private var currentData:Object;
        
        public function ICheckBox()
        {
            super();
            this.toolTip = "select";
            this.addEventListener(Event.CHANGE,changeHandle);
 			this.addEventListener(FlexEvent.DATA_CHANGE,ondc);
 			this.addEventListener(FlexEvent.CREATION_COMPLETE,oncc);
   
        }      
       private function oncc(e:FlexEvent):void
       {
       		this.selected = this.data.isSelected;
       }
       
       private function ondc(e:FlexEvent):void       
       {

       		this.selected = this.data.isSelected;
       		
       }
      

        private function changeHandle(e:Event):void
        {
        	
			this.data.isSelected = this.selected;

        	var itemArray:Array = parentApplication.checkBoxArr;
        	
        	if(this.selected)
        	{
        		itemArray.push(this.data.id);
        	}
        	else
        	{
        		 for(var i:int = 0; i<itemArray.length; i++)
        		 {
                    if(itemArray[i] == this.data.id)
                    {
                        itemArray.splice(i,1)
                    }
                }
        	}
           
        }

    }
}